import { request } from '@/utils/request';
import { Key } from 'antd/es/table/interface';

enum API {
  URL = '/metro/city',
}

/**
 * 获取分页数据
 * @param data - 请求数据
 */
export function getMetroCityPage(data: Partial<BaseFormData> & PaginationData) {
  return request.get<PageServerResult<BaseFormData[]>>(API.URL + '/page', { params: data });
}

/**
 * 根据ID获取数据
 * @param id - ID
 */
export function getMetroCityById(id: string) {
  return request.get<BaseFormData>(API.URL, { params: { id } });
}

/**
 * 新增数据
 * @param data - 请求数据
 */
export function createMetroCity(data: BaseFormData) {
  return request.post(API.URL, data);
}

/**
 * 修改数据
 * @param id - 修改id值
 * @param data - 请求数据
 */
export function updateMetroCity(id: string, data: BaseFormData) {
  return request.put(API.URL, data, { params: { id } });
}

/**
 * 删除
 * @param id - 删除id值
 */
export function deleteMetroCity(id: string) {
  return request.delete(API.URL, { params: { id } });
}

/**
 * 批量删除
 * @param data - 请求数据
 */
export function batchDeleteMetroCity(data: Key[]) {
  return request.post(API.URL + '/batchDelete', data);
}

export function getMetroCityList() {
  return request.get<BaseFormData[]>(API.URL + '/');
}
